<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div id="page-content">
    <div class="panel">
        <div class="panel-heading">
            <h3 class="panel-title">代办事项</h3>
        </div>
        <div class="panel-body">
            <div class="jqGrid_wrapper">
                <table id="toDo_table"></table>
                <div id="toDo_page"></div>
            </div>
        </div>
    </div>
</div>

<script th:inline="javascript">
    $(function(){
        init_grid_toDo();
    });

    function init_grid_toDo(){
        __init_jqgrid('toDo_table', 'toDo_page', '/flow/taskEntity/list_toDo',
            ['所属模块', '操作表', '上一步操作人','创建时间', '操作', 'id', 'keyId','readUrl'],
            [
                {name: 'module', index: 'module', width: 300, sortable: false, searchoptions: {sopt: ['cn']}},
                {name: 'tableName', index: 'tableName', width: 500, sortable: false, search: true, searchoptions: {sopt: ['cn']}},
                {name: 'lastUser.name', index: 'lastUser.name', width: 500, sortable: false, search: true, searchoptions: {sopt: ['cn']}},
                {name: 'createTime', index: 'createTime', width: 500, sortable: false, search: true, searchoptions: {sopt: ['cn']}},
                {name: 'act', index: 'act', width: 150, sortable: false, search: false, formatter: actFormat},
                {name: 'id', index: 'id', width: 100, key: true, hidden: true},
                {name: 'keyId', index: 'keyId', width: 100, hidden: true},
                {name: 'readUrl', index: 'readUrl', width: 100, hidden: true}
            ]
        );
    }

    function actFormat(cellvalue, options, rowObject) {
        var id = rowObject.id;
        cellvalue = '<button class="btn btn-default btn-xs" onclick="fn_toDo_read(\'' + id + '\');"><i class="fa fa-pencil-square-o"> </i> 查看</button> ';
        return cellvalue;
    }

    function fn_toDo_read(id){
        var data = __jqGrid_data("toDo_table", id);
        if(!data || !data.keyId || !data.readUrl){
            __toastr_warning("数据异常");
            return false;
        }
        __layX_html_read(data.keyId, data.tableName, "../"+data.readUrl);
    }

</script>

</html>